package com.owen.websocket.stomp.controller;

import lombok.extern.log4j.Log4j2;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Log4j2
@Controller
@RequestMapping("/websocket")
public class WebsocketController {

//    @Autowired
//    private SimpMessagingTemplate simpMessagingTemplate;

    @MessageMapping("/greeting")
    public String handle(String greeting){
        log.info(greeting);
        return "["+System.currentTimeMillis()+": "+greeting;
    }

    @ResponseBody
    @RequestMapping("/sendData")
    public String sendData(String data){
//        simpMessagingTemplate.convertAndSend("/topic/greeting", data);
        return "success";
    }

}
